package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.http.response.ShopOrderBean;
import com.qf.flash.mvp.contract.ShopOrderContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

/**
 * 创建日期：2020/3/8 on 10:28
 * 描述:  商家我的订单列表
 * 作者:戴旭东
 */
public class ShopOrderPresenter extends BasePresenter<ShopOrderContract.View> implements ShopOrderContract.Presenter {

    @Override
    public void getShopOrderData(String type, int pageNo) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .SHOP_ORDER_LIST(uid, type, pageNo)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<List<ShopOrderBean>>>(mRootView) {
                    @Override
                    public void onSuccess(BaseResponse<List<ShopOrderBean>> shopRes) {
                        mRootView.setShopOrder(shopRes.getData(), shopRes.getTotalPage());
                    }
                })
        );
    }
}
